PageBreakUtil = {
	view: function(fieldContext) {
		var textView = App.PageBreakDisplayView.create();
		var containerView = Em.View.views['form_canvas_view'];
		containerView.get('childViews').pushObject(textView);

		textView.set("context", fieldContext);
		
		containerView.get('childViews').sort(function(a, b) {
			return a.get("context").get("indexx") - b.get("context").get("indexx");			
		});
	},
	showPageNumb: function(fieldContext) {
		var me = this;
		var fields = $("#form_canvas_view .fieldset.pageBreak");
		var total = fields.length;
		fields.each(function (index, domEle) {
			$(domEle).find(".pageCurrent").text(index + 1);
			$(domEle).find(".pageTotal").text(total);
			
			if (index + 1 > 1) {
				me.activeLink($(domEle).find(".hasPrevious"));
			} else {
				me.disableLink($(domEle).find(".hasPrevious"));
			}
			
			if (index + 1 != total) {
				me.activeLink($(domEle).find(".hasNext"));
			} else {
				me.disableLink($(domEle).find(".hasNext"));
			}
		});
	},
	activeLink: function(elm) {
		elm.removeClass("disabled");
		elm.css("color", "black");
		elm.css("cursor", "pointer");
	},
	disableLink: function(elm) {
		elm.addClass("disabled");
		elm.css("color", "#CCC");
		elm.css("cursor", "default");
	}
};